<template>
  <div class="container">
    <div class="app-container" style="padding: 20px;">
      <el-row class="header" style="font-size: 14px;">
        <span>车牌号码：</span>
        <el-input
          v-model="queryParams.carNumber"
          size="small"
          placeholder="请输入车牌号码"
          style="width: 200px; margin: 0 10px;"
        />
        <span>缴纳状态：</span>
        <el-select
          v-model="queryParams.paymentStatus"
          size="small"
          placeholder="未选择"
          style="width: 200px; margin: 0 10px;"
        >
          <el-option label="未选择" value="" />
          <el-option label="已缴纳" value="1" />
          <el-option label="未缴纳" value="0" />
        </el-select>
        <el-button size="small" type="primary" @click="getCarStopList">查询</el-button>
      </el-row>
      <el-divider />
      <el-table :data="list" style="width: 100%">
        <el-table-column type="index" label="序号" />
        <el-table-column prop="carNumber" label="车牌号码" />
        <el-table-column prop="chargeType" label="收费类型">
          <template #default="{ row }">
            <span v-if="row.chargeType === 'card'">月卡</span>
            <span v-else>临时停车</span>
          </template>
        </el-table-column>
        <el-table-column prop="parkingTime" label="停车总时长" />
        <el-table-column prop="actualCharge" label="缴纳费用（元）" />
        <el-table-column prop="paymentStatus" label="缴纳状态">
          <template #default="{ row }">
            {{ row.paymentStatus ? '已缴费' : '未缴纳' }}
          </template>
        </el-table-column>
        <el-table-column prop="paymentMethod" label="缴纳方式">
          <template #default="{ row }">
            <span v-if="row.paymentMethod === 'Alipay'">支付宝</span>
            <span v-if="row.paymentMethod === 'WeChat'">微信</span>
            <span v-if="row.paymentMethod === 'Cash'">线下</span>
          </template>
        </el-table-column>
        <el-table-column prop="paymentTime" label="缴纳时间" />
      </el-table>
      <el-row style="margin-top: 20px;" type="flex" justify="end">
        <el-pagination
          :current-page="queryParams.page"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="queryParams.pageSize"
          layout="total, prev, pager, next, sizes, jumper"
          :total="total"
          @current-change="changePage"
          @size-change="changePageSize"
        />
      </el-row>

    </div>
  </div>
</template>

<script>
import { getCarStopListAPI } from '@/api'

export default {
  data() {
    return {
      list: [],
      total: 0,
      queryParams: {
        pageSize: 10,
        page: 1,
        carNumber: '',
        paymentStatus: ''
      }
    }
  },
  created() {
    this.getCarStopList()
  },
  methods: {
    async getCarStopList() {
      const { total, rows } = await getCarStopListAPI(this.queryParams)
      this.total = total
      this.list = rows
    },
    changePage(page) {
      this.queryParams.page = page
      this.getCarStopList()
    },
    changePageSize(pageSize) {
      this.queryParams.pageSize = pageSize
      this.getCarStopList()
    }
  }
}
</script>

<style scoped>
.container {
  padding: 20px;
}
.header {
  margin-bottom: 20px;
}
</style>
